package main

import (
	"fmt"
	"github.com/gomodule/redigo/redis"
)

var pool *redis.Pool

func init() {
	pool = &redis.Pool{
		// 0 不限制
		MaxActive:   0,
		MaxIdle:     8,
		IdleTimeout: 5000,
		Dial: func() (redis.Conn, error) {
			return redis.Dial("tcp", "127.0.0.1:6379")
		},
	}
}

func main() {

	con := pool.Get()
	defer con.Close()

	res, err := redis.Strings(con.Do("HMGet", "user1", "name", "age"))
	if err != nil {
		fmt.Println("redis HGet error is ", err)
		return
	}
	for i, v := range res {
		fmt.Printf("redis Get result is [%v][%v]\n", i, v)
	}

}
